<template>
  <div class="tab">
    <div v-for="(item,index) in tabList" :key="index" class="tab_item" :class="{'active':index === current}" @click="checkCurrent(index)">
      {{item}}
    </div>
  </div>
</template>

<script>
export default {
  name: 'VTab',
  props: {
    currentIndex: {
      type: [String, Number]
    }
  },
  data() {
    return {
      tabList: ['样式', '数据'],
      current: this.currentIndex
    }
  },
  methods: {
    checkCurrent(i) {
      this.current = i
      this.$emit('checckIndex', i)
    }
  },
  created() { },
  mounted() { }
}
</script>

<style lang="less" scoped>
.tab {
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #eee;
  .tab_item {
    padding: 15px 70px;
    cursor: pointer;
  }
  .active {
    background-color: #8f506f;
    color: white;
  }
}
</style>